﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Windows.Forms;
using System.IO;

namespace OfficeConvert
{
    /// <summary>
    /// 将pdf转换为flash
    /// by：qnl
    /// 2013-08-22
    /// </summary>
    public class PdfToFlash
    {
        /// <summary>
        /// 将pdf转换为flash
        /// </summary>
        /// <param name="sourcePath"></param>
        /// <param name="outFlashPath"></param>
        /// <returns></returns>
        public static bool DoConvert(string sourcePath,string outFlashPath)
        {
            var path = string.Format(@"{0}\pdftoflash_cmd\pdftoflash.exe ", Application.StartupPath);
            Process pr = new Process();
            pr.StartInfo.FileName = path;
            pr.StartInfo.Arguments = string.Format("{0} {1}", sourcePath, outFlashPath);
            pr.StartInfo.UseShellExecute = false;
            pr.StartInfo.RedirectStandardInput = true;
            pr.StartInfo.RedirectStandardOutput = true;
            pr.StartInfo.RedirectStandardError = true;
            pr.StartInfo.CreateNoWindow = true;
            pr.Start();
            pr.StandardInput.AutoFlush = true;
            pr.StandardInput.Flush();
            pr.WaitForExit();
            pr.Close();
            if (File.Exists(outFlashPath))
            {
                return true;
            }
            else
            {
                return false;
            }
            
        }
    }
}
